package com.idione.model;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBSQLiteHelper extends SQLiteOpenHelper {
	
	private static final String TAG = "DBSQLiteHelper";
	private static final int VERSION = 1;
	private static final String DATABASE_NAME = "Guidare";

	public DBSQLiteHelper(Context context) {
		super(context, DATABASE_NAME, null, VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(QuestionSQLAdapter.CREATE_STATEMENT);
		db.execSQL(SignSQLAdapter.CREATE_STATEMENT);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(TAG, "Upgrading database from version " + oldVersion 
				+ " to " + newVersion + ", which will destroy all old data");

		db.execSQL("drop table if exists " + QuestionSQLAdapter.TABLENAME);
		db.execSQL(QuestionSQLAdapter.CREATE_STATEMENT);

		db.execSQL("drop table if exists SignQuestion");
		db.execSQL(SignSQLAdapter.CREATE_STATEMENT);
	}

}
